import { ref } from 'vue'
import { useEvent } from './event.js'

// 自定义 Hook 一定要以 use 开头
export const useMouse = () => {
  const x = ref(0)
  const y = ref(0)

  // const update = (e) => {
  //   x.value = e.pageX
  //   y.value = e.pageY
  // }

  useEvent(window, 'mousemove', (e) => {
    x.value = e.pageX
    y.value = e.pageY
  })

  return { x, y }
}
